//index.js
const app = getApp()
Page({
  data: {
    disabled: true,
    userInfo: {},
    start_time:'1867',
    end_time:'2017',
    year: '',
  },
  onLoad: function () {
    let that = this;
    let logs = wx.getStorageSync('user_info') || {};
    let data = Date.now() - logs.data < 0*24*60*60*1000 ? true : false;
    if (logs.age && data ){
      wx.redirectTo({
        url: '../home/home'
      })
    }
    app.getUserInfo(function(userInfo){
      // console.log(userInfo)
      that.setData({
        userInfo:userInfo
      })
    })
  },
  sle_year: function(e) {
    let year = e.detail.value;
    this.setData({
      disabled: false,
      year: year
    })
  },
  formSubmit: function(e) {
    let age = e.detail.value.age,user_info={};
    let data = new Date();
    user_info.age = data.getFullYear() - age;
    user_info.data = Date.now();
    wx.setStorage({
      key: "user_info",
      data: user_info,
      success: function() {
        wx.redirectTo({
          url: '../home/home'
        })
      }
    })
  }
})
